package com.pactera.elasticsearch.autoconfigure;

import com.pactera.elasticsearch.service.ElasticService;
import com.pactera.elasticsearch.service.ElasticServiceImpl;
import com.pactera.elasticsearch.utils.SpringScanUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

/**
 * elasticsearch配置类
 *
 * @author: liqingdian
 */
@Configuration
@EnableConfigurationProperties({ElasticsearchProperties.class})
@Import({ElasticsearchConfiguration.class, SpringScanUtils.class})
public class ElasticsearchAutoConfiguration {
    private static final Logger log = LoggerFactory.getLogger(ElasticsearchAutoConfiguration.class);

    @Bean
    @ConditionalOnMissingBean(name = {"elasticService"})
    public ElasticService elasticService() {
        ElasticServiceImpl elasticService = new ElasticServiceImpl();
        log.info("elasticService-ElasticService初始化成功");
        return elasticService;
    }
}
